import HTTP from '../utils/http';
import { API } from '../config/config';
import { Message } from 'element-ui';
import { axiosMessageShow, findAssign } from '@/utils/tools';
const ESSAY = API.ESSAY;
export default class EssayClass extends HTTP{
    findEssay(id) {
      return new Promise((resolve)=>{
        this.axiosPost({
            url:ESSAY.ESSAY_GET,
            data:id,
            success(data){
                axiosMessageShow(data);
                resolve(data)
            },error(error){
                Message({
                    message:error,
                    type:'error'
                })
            }
        })
      })  
    }
    findEssayAssign(params){
        const { title, type } = params;
        let data = findAssign(title,type)
        if(!data){
            Message({
                message:"查询失败！",
                type:'error'
            })
        }
        Message({
            message:"查询成功！",
            type:'success'
        })
        return data;
    } 
    createEssay(data){
        return new Promise((resolve)=>{
            this.axiosPostFromdata({
                url:ESSAY.ESSAY_CREATE,
                data,
                success(data){
                    axiosMessageShow(data);
                    resolve(data)
                },error(error){
                    Message({
                        message:error,
                        type:'error'
                    })
                }
            })
          })  
    }
    updateEssay(data){
        
    }

}